﻿using System;
using System.IO;
using System.Drawing;
using System.Diagnostics;
using System.Windows.Forms;

//自定义命名空间
using DreamCube.Foundation.DllImport;
using BasicUtility = DreamCube.Foundation.Basic.Utility;

namespace BGN.PlugIn.Client.LoginSinfoTool
{
    /// <summary>
    /// 登陆Sinfo系统的插件
    /// </summary>
    public class LoginSinfoPlugIn : SisenMESS_Interface.SisenMESS_Tools_Interface
    {
        #region "字段"

        /// <summary>
        /// 标志模块是否已经打开
        /// </summary>
        private Boolean isLogined = false;

        /// <summary>
        /// 上一次单击的时间
        /// </summary>
        private DateTime lastClickTime = System.DateTime.Now;

        #endregion

        #region "事件"

        public event SisenMESS_Interface.OnRequestSetFormLocationEventArgsHandler OnSetFormLocation;

        public event SisenMESS_Interface.OnRequestSetFormSizeEventArgsHandler OnSetFormSize;

        #endregion

        #region "属性"

        public string _Company
        {
            get { return LoginSinfoPlugInConfiger.Instance.GetCompanyName(); }
        }

        public string _ID
        {
            get { return LoginSinfoPlugInConfiger.Instance.GetXmlConfigNodePropertyValue("", "ID"); }
        }

        public System.Drawing.Image _Icon
        {
            get
            {
                try
                {
                    String path = Path.Combine(BasicUtility.MyDll.GetCurrentDllPath(), LoginSinfoPlugInConfiger.Instance.GetIcon());
                    return Image.FromFile(path);
                }
                catch (Exception ex)
                {
                    BasicUtility.MyLog.MakeLog(ex);
                }
                return Properties.Resources.login;
            }
        }

        public string _Product
        {
            get { return LoginSinfoPlugInConfiger.Instance.GetProduct(); }
        }

        public bool _IsLogined
        {
            get { return false; }
            set { isLogined = false; }
        }

        public string _ServerIp
        {
            get;
            set;
        }

        public string _UserId
        {
            get;
            set;
        }

        public string _UserName
        {
            get;
            set;
        }

        public string _UserNo
        {
            get;
            set;
        }

        public string _UserPassWord
        {
            get;
            set;
        }

        #endregion

        #region "方法"

        /// <summary>
        /// 加一个默认的构造函数
        /// </summary>
        public LoginSinfoPlugIn()
        { }

        public void _Show()
        {
            try
            {
                IEWinHelper.OpenOASystem(this._UserNo,this._UserName, this._UserPassWord, LoginSinfoPlugInConfiger.Instance.GetXmlConfigNodeInnerText("BrowserUrlPath"));
            }
            catch (Exception ex)
            {
                DreamCube.Foundation.Basic.Utility.MyLog.MakeLog(ex);
                MessageBox.Show("登陆SInfo系统发生异常，请联系管理员！", "错误提醒");
            }
        }

        #endregion
    }
}
